import wepy from 'wepy'
export default class extends wepy.mixin {
  data = {
    swiper: [],
    cates: [],
    floorData: []
  }

  config = {}

  methods = {
    goToDetail(url) {
      wepy.navigateTo({ url })
    }
  }
  // 获取轮播图
  async getSwiper() {
    const { data: res } = await wepy.get('/home/swiperdata')
    wepy.baseToast(res)
    this.swiper = res.message
    this.$apply()
  }
  // 获取分类
  async getCates() {
    const { data: res } = await wepy.get('/home/catitems')
    wepy.baseToast(res)
    this.cates = res.message
    this.$apply()
  }
  // 获取楼层
  async getFloorData() {
    const { data: res } = await wepy.get('/home/floordata')
    wepy.baseToast(res)
    this.floorData = res.message
    this.$apply()
  }

  onLoad() {
    this.getSwiper()
    this.getCates()
    this.getFloorData()
  }
  onShow() {
    this.$parent.changeBandge()
  }
}